﻿# -*- coding: utf-8 -*-
import re       # 调用正则模块
with open('/习题/from.txt', encoding='utf8') as f:      # 打开文件
    r = f.read()        # 读取文件内容
w = re.findall(r"\b[A-z]+\b", r)        # 提取单词
w.sort()        # 对单词排序
a = '\n'.join(w)        # 拼接成一个字符串
with open('to.txt', 'w', encoding='utf8') as f:     # 写入新文件
    f.write(a)